package com.secsys.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateFormatUtils {
	private static final long DateTime=86400000;   //一天时间
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private static final SimpleDateFormat y_m_d_h_m_s_DateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	/**
	 * 
	 * @Description 将yyyy-MM-dd格式的Date转换成string
	 * @param date
	 *            格式为yyyy-MM-dd 的date类型
	 * @return
	 */
	public static String convertDateToString(Date date) {
		return date != null ? dateFormat.format(date) : "";
	}
    /**
     * 
     * @Description 将yyyy-MM-dd HH:mm:ss Date类型转换成相应的字符串
     * @param date
     * @return
     */
	public static String convertDateTimeToString(Date date) {
		return date != null ? dateTimeFormat.format(date) : "";
	}
   /**
    * 
    * @Description 将date字符串转换成Date
    * @param dateStr
    * @return
    */
	public static Date convertStringToDate(String dateStr) {
		try {
			return dateStr != null ? dateFormat.parse(dateStr) : null;
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static long getDateTime(){
		 return DateTime;
	}
	public static Date convertStringToDateTime(String dateTimeStr){
		try {
			return dateTimeStr!=null?dateTimeFormat.parse(dateTimeStr):null;
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
	
	public static void main(String[] args) throws ParseException {
		  Calendar calendar=Calendar.getInstance();
		  Date date=new Date();
		    
		  System.out.println(calendar.getTime());
		      
	    
	  
		
	}
}
